﻿using System;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 配置文件夹目录结构
/// </summary>
[Serializable]
[CreateAssetMenu(menuName = "CreateInsertDirCfg", fileName = "InsertDirCfg", order = 0)]
public class InsertDirCfg : ScriptableObject
{
    #region Default
    readonly string[] FolderLayer0_0 = new string[] { "GameDatas" };
    readonly string[] FolderLayer1_0 = new string[] { "Environments", "Datas", "Models", "Prefabs", "Materials"
        , "Textures","Scenes","Shaders","Audios","Sprites"
    };
    readonly string[] FolderLayer2_0 = new string[] { "Models", "Materials", "Textures", "Shaders", "Prefabs" };
    readonly string[] FolderLayer2_3 = new string[] { "Effects", "UI" };

    /// <summary>
    /// 创建实例时默认创建目录结构
    /// + GameDatas
    /// ++ Environments
    /// +++ Models
    /// +++ Materials
    /// +++ Textures
    /// +++ Shaders
    /// +++ Prefabs
    /// ++ Datas
    /// ++ Models
    /// ++ Prefabs
    /// +++ Effects
    /// +++ UI
    /// ++ Materials
    /// ++ Textures
    /// ++ Scenes
    /// ++ Shaders
    /// ++ Audios
    /// ++ Sprites
    /// </summary>
    public InsertDirCfg() : base()
    {
        Debug.Log("InsertDirCfg Create");

        DirList = new List<LinkNode>();

        for (int i = 0; i < FolderLayer0_0.Length; i++)
        {
            LinkNode node = new LinkNode(FolderLayer0_0[i]);

            if (i == 0)
            {
                for (int j = 0; j < FolderLayer1_0.Length; j++)
                {
                    LinkNode node0 = new LinkNode(FolderLayer1_0[j]);

                    if (j == 0)
                    {
                        for (int k = 0; k < FolderLayer2_0.Length; k++)
                        {
                            LinkNode node1 = new LinkNode(FolderLayer2_0[k]);

                            node0.NextList.Add(node1);
                        }
                    }
                    else if (j == 3)
                    {
                        for (int k = 0; k < FolderLayer2_3.Length; k++)
                        {
                            LinkNode node1 = new LinkNode(FolderLayer2_3[k]);

                            node0.NextList.Add(node1);
                        }
                    }

                    node.NextList.Add(node0);
                }
            }

            DirList.Add(node);
        }
    }
    #endregion

    public List<LinkNode> DirList;
}

[Serializable]
public class LinkNode
{
    public string FolderName;

    public List<LinkNode> NextList;

    public LinkNode(string folderName)
    {
        FolderName = folderName;
        NextList = new List<LinkNode>();
    }
}
